<style>
	.hover-info{
		cursor: pointer;
	}
	.result-hover{
		position: absolute;
		display: none;
		border: 1px solid #C0C0C0;
		background: #F9FAFB;
		padding: 0 8px 5px 8px;
		font-size: 11px;
	}
	.result-hover > h4{
		text-align: center;
		text-transform: uppercase;
		font-size: 11px;
		margin: 8px 0;
	}
	.result-hover li{
		padding: 2px 0;
		overflow: hidden;
	}
	.ul1 .first{
		display: inline-block;
		float: left;
		width: 110px;
	}
</style>
<script>
	jQuery(document).ready(function($) {
		$( "#dialogModal" ).dialog({
			height: 'auto',
			width: 'auto',
			autoOpen: false,
			show: {
				effect: "blind",
				duration: 200
				
				},
			hide: {
				effect: "blind",
				duration: 200
				},
			modal: true,
		});
		$(".items, .link-dialog").click(function(event){
			event.preventDefault();
			$('#contentWrap').load($(this).attr("href"));  //load content from href of link
			$('#dialogModal').dialog('option', 'title', $(this).attr("title"));  //make dialog title that of link
			$('#dialogModal').dialog('open');  //open the dialog
		});
		$(".hover-info").hover(function(event) {
			var left = event.pageX+'px';
            var top = event.pageY+'px';
            $(".result-hover").css({
                'display': 'inline-block',
                'z-index' : '99999',
                'top': top,
                'left': left
            });

            $.ajax({
                data: {"id": $(this).attr('id')},
                url: "<?php echo $this->webroot.'guests/infomation' ?>",
                success: function(data){
                    var data = $.parseJSON(data);
                    $('.ul1 #l1').html(data[0]['Guest']['name']);
                    var gt = 'Nam';
                    if(data[0]['Guest']['gioitinh'] == 0){
                    	gt = 'Nữ';
                    }
                    $('.ul1 #l2').html(gt);
                    $('.ul1 #l3').html(data[0]['Guest']['ngaysinh']);
                    $('.ul1 #l4').html(data[0]['Guest']['address']);
                    $('.ul1 #l5').html(data[0]['Guest']['phone']);
                    $('.ul1 #l6').html(data[0]['Guest']['cmt']);
                    var arr_elment = [];
                    $.each(data[0]['Reservation'], function( index, value) {
                    	if(value['status'] == 1){
                    		arr_elment.push('<li><span style="display: inline-block; width: 110px;">Đang ở phòng : <span>'+value['Room']['name']+'</span></span>Từ <span>'+value['start']+'</span> đến <span>'+value['end']+'</span></li>');
                    	}else if(value['status'] == 2){
                    		arr_elment.push('<li><span style="display: inline-block; width: 110px;">Đặt phòng : <span>'+value['Room']['name']+'</span></span>Từ <span>'+value['start']+'</span> đến <span>'+value['end']+'</span></li>');
                    	}
                    });
                    if(arr_elment.length > 0){
                    	$('.ul2').html(arr_elment);
                    }else{
                    	$('.ul2').html("<li>Khách hàng này đang chờ xếp phòng</li>");
                    }
                }
            });
		}, function(event) {
			$(".result-hover").css('display', 'none');
		});
	});
</script>

<div class="result-hover">
	<h4>thông tin khách hàng</h4>
	<ul class="ul1">
		<li><span class="first">Khách hàng :</span><span class="last" id="l1"></span></li>
		<li><span class="first">Giới tính :</span><span class="last" id="l2"></span></li>
		<li><span class="first">Ngày sinh :</span><span class="last" id="l3"></span></li>
		<li><span class="first">Địa chỉ :</span><span class="last" id="l4"></span></li>
		<li><span class="first">Điện thoại :</span><span class="last" id="l5"></span></li>
		<li><span class="first">Số CMT/Passport :</span><span class="last" id="l6"></span></li>
	</ul>
	<h4 style="text-align: left;">Hiện trạng</h4>
	<ul class="ul2">
		
	</ul>
</div>

<div id="dialogModal">
     <!-- the external content is loaded inside this tag -->
     <div id="contentWrap"></div>
</div>
<ul class="context-menu">
    <li>
    	<?php echo $this->Html->link('Thông tin phòng', array('controller' => 'rooms','action' => 'information'), array('class' => 'inf-room', 'title'=>'Thông tin chi tiết phòng')); ?>
    </li>
    <li>
		<?php echo $this->Html->link('Danh sách khách hàng đặt phòng', array('controller'=>'reservations','action' => 'list_guest'), array('class' => 'list-booking', 'title'=>'Danh sách khách hàng đã đặt phòng')) ?>
    </li>
    <li>
    	<?php echo $this->Html->link('Danh sách khách hàng đang ở', array('controller' => 'reservations','action' => 'list_guest_cur'), array('class' => 'list-guest', 'title'=>'Danh sách khách hàng đang ở')); ?>	
    </li>
    <li><a href="javascript:void(0)" class="service">Xem/Thêm dịch vụ</a></li>
    <li>
    	<?php echo $this->Html->link('Chuyển phòng', array('controller' => 'reservations', 'action' => 'move_room'), array('style' => 'display: none','title' => 'Chuyển phòng')); ?>
    </li>
</ul>
<div id="list-room">
	<div class="title-block">
		<h1 class="h1">Danh sách phòng</h1>
		<?php
			// Đoạn này không được xóa - Đang khóa tạm thời CuongNV
			// echo $this->Form->create('Reservation');
			// $h = array();
			// for ($i=0; $i < 24; $i++) { 
			// 	$h[] = $i;
			// }
			// $p = array();
			// for ($j=0; $j < 60; $j++) { 
			// 	$p[] = $j;
			// }
			// echo '<div class="in">';
			// 	echo $this->Form->input('date_in', array('div' => false,'class' => 'datepicker','placeholder' => 'Ngày vào ...','label' => ''));
			// 	echo $this->Form->input('h_in', array('options' =>$h, 'div' => false,'label'=>false));
			// 	echo $this->Form->input('p_in', array('options' =>$p, 'div' => false,'label'=>false));
			// echo '</div>';
			// echo '<div class="out">';
			// 	echo $this->Form->input('date_out', array('div' => false,'class' => 'datepicker','placeholder' => 'Ngày ra ...','label'=>false));
			// 	echo $this->Form->input('h_out', array('options' =>$h, 'div' => false,'label'=>false));
			// 	echo $this->Form->input('p_out', array('options' =>$p, 'div' => false,'label'=>false));
			// echo '</div>';
			// echo $this->Form->submit("Tìm phòng trống", array('div' => false,'id'=>'SearchRoom'));
			// echo $this->Form->end();
		?>
		<ul>
			<a href="#"><li><img title="Chuyển đổi tiền tệ" src="<?php echo $this->webroot;?>img/icons/currency_blue_dollar.png" alt="Quy đổi tiền tệ"></li></a>
			<a href="#"><li><img title="Nhật ký công việc" src="<?php echo $this->webroot;?>img/icons/Notepad.png" alt="Nhật ký công việc"></li></a>
			<a href="#"><li><img title="Hiện trạng phòng" src="<?php echo $this->webroot;?>img/icons/cal3.gif" alt="Hiện trạng phòng"></li></a>
			<a href="#"><li><img title="Báo cáo" src="<?php echo $this->webroot;?>img/icons/reports.png" alt="Báo cáo"></li></a>
		</ul>
	</div>
	<div class="it-wrap">
		<div id="loading"></div>
		<div id="status-bar">
			<ul class="status">
				<li><span><?php echo count($rooms)-count($arr_id_book)-count($arr_id_cur); ?></span>&nbsp;<label>Còn trống</label></li>
				<li><span id="placed"><?php echo count($arr_id_book); ?></span>&nbsp;<label>Đã đặt</label></li>
				<li><span id="are-at"><?php echo count($arr_id_cur); ?></span>&nbsp;<label>Đang ở</label>
				</li>
			</ul>

			<ul class="criteria">
				<li>
					<input type="radio" name="type" id="r1" checked><label for="1"> Rút gọn</label>
				</li>
				<li>
					<input type="radio" name="type" id="r2"><label for="2"> Theo lầu</label>
				</li>
				<li>
					<input type="radio" name="type" id="r3"><label for="3"> Loại phòng
				</label>
				</li>
			</ul>
		</div>
		<div class="r1 list">
			<?php
				foreach ($rooms as $key => $valuer) {
					if(array_key_exists($valuer['Room']['id'],$arr_demo)){
						$background = "background: #ED872F; color: #FFF; border: none;";
						$title = "Hóa đơn";
						$href = $this->webroot."bills/edit/".$valuer['Room']['id']."/".$arr_demo[$valuer['Room']['id']];
					}elseif (in_array($valuer['Room']['id'],$arr_id_book)) {
						$background = "background: #3994C5; color: #FFF; border: none;";
						$href = $this->webroot."reservations/book/";
						$title = "Nhận phòng";
					}else {
						$background = "border: 1px solid #C0C0C0;";
						$href = $this->webroot."reservations/book/";
						$title = "Đặt phòng";
					}
			?>
				<a href=<?php echo $href.$valuer['Room']['id']; ?> class="items" style="<?php echo $background; ?>" id="<?php echo $valuer['Room']['id']; ?>" title="<?php echo $title; ?>"><?php echo $valuer['Room']['name']; ?></a>
			<?php } ?>
		</div>
		<div class="r2 list2 hidden">
		<?php
			foreach ($room_storey as $value) {
		?>                 
			<div class="gr-room">
				<h4><?php echo $value['Storey']['type']; ?></h4>
				<div class="wrapp-list">
					<?php
						if(count($value['Room']) == 0){
							echo '<h3 style="font-weight: normal; font-size: 13px; color :#006699; margin-bottom: 20px;">Không tồn tại phòng tại lầu này</h3>';
						}else{
							foreach ($value['Room'] as $val) {
								if(array_key_exists($val['id'],$arr_demo)){
									$background = "background: #ED872F; color: #FFF; border: none;";
									$href = $this->webroot."bills/edit/".$val['id']."/".$arr_demo[$val['id']];
									$title = "Hóa đơn";
								}elseif (in_array($val['id'],$arr_id_book)) {
									$background = "background: #3994C5; color: #FFF; border: none;";
									$href = $this->webroot."reservations/book/";
									$title = "Nhận phòng";
								}else {
									$background = "border: 1px solid #C0C0C0;";
									$href = $this->webroot."reservations/book/";
									$title = "Đặt phòng";
								}
							?>
								<a title="<?php echo $title; ?>" href="<?php echo $href.$val['id']; ?>" class="items" style="<?php echo $background; ?>" id="<?php echo $val['id']; ?>">
									<?php echo $val['name']; ?>
								</a>
					<?php } } ?>
				</div>
			</div>
		<?php } ?>
		</div>
		<div class="r3 list3 hidden">
			<?php
				foreach ($room_cate as $value) { ?>
					<div class="gr-room">
						<h4><?php echo $value['Cateroom']['name']."&nbsp;&nbsp; ( ".number_format($value['Cateroom']['price_date'])." VNĐ )"; ?>
						</h4>
						<div class="wrapp-list">
							<?php
								if(count($value['Room']) == 0){
									echo '<h3 style="font-weight: normal; font-size: 13px;
									color :#006699; margin-bottom: 20px;">
									Không tồn tại phòng thuộc danh mục này
									</h3>';
								}else{
									foreach ($value['Room'] as $val) {
										if(array_key_exists($val['id'],$arr_demo)){
											$background = "background: #ED872F; color: #FFF; border: none;";
											$href = $this->webroot."bills/edit/".$val['id']."/".$arr_demo[$val['id']];
											$title = "Hóa đơn";
										}elseif (in_array($val['id'],$arr_id_book)) {
											$background = "background: #3994C5; color: #FFF; border: none;";
											$href = $this->webroot."reservations/book/";
											$title = "Nhận phòng";
										}else {
											$background = "border: 1px solid #C0C0C0;";
											$href = $this->webroot."reservations/book/";
											$title = "Đặt phòng";
										}
									?>
										<a title="<?php echo $title; ?>" href="<?php echo $href.$val['id']; ?>" class="items" style="<?php echo $background; ?>" id="<?php echo $val['id']; ?>">
											<?php echo $val['name']; ?>
										</a>
							<?php 	}
								}
							?>
						</div>
					</div>
			<?php } ?>
		</div>
	</div>
</div>

<div class="list-customer" id="guest_waiting">
	<div class="title-block">
		<h1 class="h1">Danh sách khách hàng chờ xếp phòng</h1>
		<div class="block-form">
<!-- 			<form action="#">
				<input type="text" placeholder="Nhập thông tin cần tìm kiếm ...">
				<input type="submit" value="Tìm kiếm">
			</form> -->
		</div>
	</div>
	<div class="action-listcus">
		<div class="block-listcus">
			<table cellspacing="0" cellpadding="0">
				<tr>
					<th class="id"><input class="chk-parent1" type="checkbox" value="1"></th>
					<th class="name">Họ tên</th>
					<th class="sex">Giới tính</th>
					<th class="address">Địa chỉ</th>
					<th class="code">CMND/Passport</th>
					<th class="phone">Điện thoại</th>
					<th class="action">Thao tác</th>
				</tr>
				<?php
					foreach ($guest_waiting as $value) {
				?>
 					<tr>
						<td class="id"><input class="chk-sub1" type="checkbox"
							value="<?php echo $value['guests']['id']; ?>">
						</td>
						<td class="name hover-info" id="<?php echo $value['guests']['id'] ?>">
							<?php echo $value['guests']['name']; ?>
						</td>
						<td class="sex">
							<?php
								echo ($value['guests']['gioitinh'] == 1) ? 'Nam' : 'Nữ';
							?>
						</td>
						<td class="address"><?php echo $value['guests']['address']; ?></td>
						<td class="code"><?php echo $value['guests']['cmt']; ?></td>
						<td class="phone"><?php echo $value['guests']['phone']; ?></td>
						<td class="action">
							<?php echo $this->Html->link($this->Html->image("icons/edit-icon.png", array("alt" => "Sửa", 'style' => 'width: 16px; height: 16px;')), array('controller' => 'guests', 'action' => 'edit', $value['guests']['id']), array('class' => 'edit', 'title' => 'Cập nhật', 'escape' => false, 'style'=>'margin-right: 14px;')); ?>
							<?php echo $this->Html->link($this->Html->image("icons/Delete-icon.png", array("alt" => "Xóa", 'style' => 'width: 13px; height: 13px;')), array('controller' => 'guests', 'action' => 'delete', $value['guests']['id']), array('class' => 'del_book', 'title' => 'Xóa', 'escape' => false, 'style'=>'margin-right: 12px;')); ?>
							<?php echo $this->Html->link($this->Html->image("icons/open-key-icon.png", array("alt" => "Đặt phòng", 'style' => 'width: 14px; height: 14px;')), array('controller' => 'reservations', 'action' => 'received', $value['guests']['id'],0,'?' => array('name' => $value['guests']['name'], 'cmt' => $value['guests']['cmt'])), array('class' => 'link-dialog', 'title' => 'Đặt phòng', 'escape' => false)); ?>
						</td>
					</tr>
				<?php } ?>
			</table>
		</div>
		<div class="page" style="margin-bottom: 14px;">
 			<p>Có tổng số <span style="font-weight: bold; color: #ED872F;">
				<?php echo $sum_gw; ?>
			</span> khách hàng chờ xếp phòng</p>
		</div>
		<div class="block-action cus-page">
			<form action="#" id="waiting-form">
				<input type="submit" value="Xóa tùy chọn" id="set-waiting">
			</form>
			<ul class="page">
				<?php
					if($page1 > 1){
					for ($i= 1; $i <= $page1 ; $i++) {
						$style = "";
						if(isset($_GET['pw']) && $_GET['pw'] == $i){
							$style = "background: #01B1D3; color: #FFF; border: 1px solid #01B1D3;";
						}
				?>
					<li><a style="<?php echo $style ?>" href="?pw=<?php echo $i ?>"><?php echo $i; ?></a></li>
				<?php } } ?>
			</ul>
		</div>
	</div>
</div>


<div class="list-customer">
	<div class="title-block">
		<h1 class="h1">Danh sách khách hàng đã đặt phòng</h1>
		<div class="block-form">
<!-- 			<form action="#">
				<input type="text" placeholder="Nhập thông tin cần tìm kiếm ...">
				<input type="submit" value="Tìm kiếm">
			</form> -->
		</div>
	</div>
	<div class="action-listcus">
		<div class="block-listcus">
			<table cellspacing="0" cellpadding="0">
				<tr>
					<th class="id"><input class="chk-parent2" type="checkbox" value="1"></th>
					<th class="name">Họ tên</th>
					<th class="sex">Giới tính</th>
					<th class="address">Địa chỉ</th>
					<th class="code">CMND/Passport</th>
					<th class="phone">Điện thoại</th>
					<th class="action">Thao tác</th>
				</tr>
				<?php
					$c1 = count($guest_book);
					foreach ($guest_book as $value) {
				?>
 					<tr>
						<td class="id">
							<input class="chk-sub2" type="checkbox" value="<?php echo $value['Guest']['id']; ?>">
						</td>
						<td class="name hover-info" id="<?php echo $value['Guest']['id'] ?>"><?php echo $value['Guest']['name']; ?></td>
						<td class="sex">
							<?php
								echo ($value['Guest']['gioitinh'] == 1) ? 'Nam' : 'Nữ';
							?>
						</td>
						<td class="address"><?php echo $value['Guest']['address']; ?></td>
						<td class="code"><?php echo $value['Guest']['cmt']; ?></td>
						<td class="phone"><?php echo $value['Guest']['phone']; ?></td>
						<td class="action">
							<?php echo $this->Html->link($this->Html->image("icons/edit-icon.png", array("alt" => "Sửa", 'style' => 'width: 16px; height: 16px;')), array('controller' => 'guests', 'action' => 'edit', $value['Guest']['id']), array('class' => 'edit', 'title' => 'Cập nhật', 'escape' => false, 'style'=>'margin-right: 14px;')); ?>
							<?php echo $this->Html->link($this->Html->image("icons/Delete-icon.png", array("alt" => "Hủy", 'style' => 'width: 13px; height: 13px;')), array('controller' => 'reservations', 'action' => 'delete', $value['Guest']['id']), array('class' => 'del_book', 'id' =>'remov', 'title' => 'Hủy đặt phòng', 'escape' => false, 'style'=>'margin-right: 12px;')); ?>
							<?php echo $this->Html->link($this->Html->image("icons/open-key-icon.png", array("alt" => "Nhận phòng", 'style' => 'width: 14px; height: 14px;')), array('controller' => 'reservations', 'action' => 'received', $value['Guest']['id'],1,'?' => array('name' => $value['Guest']['name'], 'cmt' => $value['Guest']['cmt'])), array('class' => 'link-dialog', 'title' => 'Nhận phòng', 'escape' => false)); ?>
						</td>
					</tr>
				<?php } ?>
			</table>
		</div>
		<div class="page" style="margin-bottom: 14px;">
 			<p>Có tổng số <span style="font-weight: bold; color: #ED872F;">
				<?php echo $sum_gb ?>
			</span> khách hàng đã đặt phòng</p>
		</div>
		<div class="block-action cus-page">
			<input type="button" style="padding: 4px 10px; border: 1px solid #C0C0C0; cursor: pointer;" value="Hủy đặt phòng" id="action-book">
			<ul class="page">
				<?php
					if($page3 > 1){
					for ($i= 1; $i <= $page3 ; $i++) {
						$style = "";
						if(isset($_GET['pb']) && $_GET['pb'] == $i){
							$style = "background: #01B1D3; color: #FFF; border: 1px solid #01B1D3;";
						}
				?>
					<li><a style="<?php echo $style ?>" href="?pb=<?php echo $i ?>"><?php echo $i; ?></a></li>
				<?php } } ?>
			</ul>
		</div>
	</div>
</div>
<div class="list-customer">
	<div class="title-block">
		<h1 class="h1">Danh sách khách hàng đang ở</h1>
		<div class="block-form">
<!-- 			<form action="#">
				<input type="text" placeholder="Nhập thông tin cần tìm kiếm ...">
				<input type="submit" value="Tìm kiếm">
			</form> -->
		</div>
	</div>
	<div class="action-listcus">
		<div class="block-listcus">
			<table cellspacing="0" cellpadding="0" id="changed">
				<tr>
					<th class="name" style="text-align: left;">Họ tên</th>
					<th class="sex">Giới tính</th>
					<th class="address">Địa chỉ</th>
					<th class="code">CMND/Passport</th>
					<th class="phone">Điện thoại</th>
					<th class="action">Thao tác</th>
				</tr>
				<?php
					foreach ($guest_curr as $value) {
				?>
					<tr>
						<td class="name hover-info" id="<?php echo $value['Guest']['id'] ?>"><?php echo $value['Guest']['name']; ?></td>
						<td class="sex">
							<?php
								echo ($value['Guest']['gioitinh'] == 1) ? 'Nam' : 'Nữ';
							?>
						</td>
						<td class="address"><?php echo $value['Guest']['address']; ?></td>
						<td class="code"><?php echo $value['Guest']['cmt']; ?></td>
						<td class="phone"><?php echo $value['Guest']['phone']; ?></td>
						<td class="action">
							<?php echo $this->Html->link($this->Html->image("icons/edit-icon.png", array("alt" => "Sửa", 'style' => 'width: 16px; height: 16px;')), array('controller' => 'guests', 'action' => 'edit', $value['Guest']['id']), array('class' => 'edit', 'title' => 'Cập nhật thông tin khách hàng', 'escape' => false, 'style'=>'margin-right: 14px;')); ?>

							<?php echo $this->Html->link($this->Html->image("icons/open-key-icon.png", array("alt" => "Đặt phòng", 'style' => 'width: 14px; height: 14px;')), array('controller' => 'reservations', 'action' => 'received', $value['Guest']['id'],0,'?' => array('name' => $value['Guest']['name'], 'cmt' => $value['Guest']['cmt'])), array('class' => 'link-dialog', 'title' => 'Đặt phòng', 'escape' => false)); ?>

							<?php echo $this->Html->link($this->Html->image("icons/money.png", array("alt" => "Check out", 'style' => 'height: 16px;')), array('controller' => 'bills', 'action' => 'payment', $value['Guest']['id']), array('class' => 'link-dialog', 'title' => 'Check out', 'escape' => false, 'style'=>'margin-left: 14px;')); ?>
						</td>
					</tr>
				<?php } ?>
			</table>
		</div>
  		<div class="page">
 			<p>Có tổng số <span style="font-weight: bold; color: #ED872F;">
				<?php echo $sum_gc ?></span> khách hàng đang ở</p>
			<ul class="page">
			<?php
				if($page2 > 1){
				for ($i= 1; $i <= $page2 ; $i++) {
					$style = "";
					if(isset($_GET['pc']) && $_GET['pc'] == $i){
						$style = "background: #01B1D3; color: #FFF; border: 1px solid #01B1D3;";
					}
			?>
				<li><a style="<?php echo $style ?>" href="?pc=<?php echo $i ?>"><?php echo $i; ?></a></li>
				<?php } } ?>
			</ul>
		</div>
	</div>
</div>